package com.safe.ocs.services;

import java.util.List;

import net.sf.json.JSONObject;

import org.hibernate.Session;

import com.safe.ocs.beans.OMsgPageBean;
import com.safe.ocs.utils.HibernateUtil;

public class CViewMsg {
	
	public String findMessage(int start , int limit){
		Session session = HibernateUtil.getSession();
		String findHql ="select new OutputSMS(ID,telNo,msg,sendedStaut,remarks) from OutputSMS";
		int totalProperty = session.createQuery(findHql).list().size();
		List msgList = session.createQuery(findHql).setFirstResult(start).setMaxResults(limit).list();
		OMsgPageBean bean = new OMsgPageBean(totalProperty,msgList);
		JSONObject result = JSONObject.fromObject(bean);
		System.out.println(result.toString());
		return result.toString();
		
	}

}